#!/usr/bin/env python

import os
import cobra
import crypt

class UserAdder:

    def addUser(self, user, password):
        salt = os.urandom(4).encode("base64")[:2]
        cryptpass = crypt.crypt(password, salt)
        #print "Adding User:",user,cryptpass
        os.system("/usr/local/bin/makeuser %s %s" % (user, cryptpass))

if __name__ == "__main__":
    adder = UserAdder()
    daemon = cobra.CobraDaemon(port=4444)
    daemon.shareObject(adder, "UserAdder")
    daemon.serve_forever()

